﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbSortentsTable : OdDbObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbSortentsTable(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbSortentsTable_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbSortentsTable obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbSortentsTable()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbSortentsTable(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbSortentsTable cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSortentsTable_cast(OdRxObject.getCPtr(pObj));
			OdDbSortentsTable result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSortentsTable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSortentsTable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSortentsTable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSortentsTable_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSortentsTable_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSortentsTable_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbSortentsTable createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSortentsTable_createObject();
			OdDbSortentsTable result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSortentsTable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSortentsTable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSortentsTable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getSortHandle(OdDbObjectId id, OdDbHandle h)
		{
			TD_DbPINVOKE.OdDbSortentsTable_getSortHandle(this.swigCPtr, OdDbObjectId.getCPtr(id), OdDbHandle.getCPtr(h));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void moveToBottom(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSortentsTable_moveToBottom(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void moveToTop(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSortentsTable_moveToTop(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void moveBelow(OdDbObjectIdArray entityIds, OdDbObjectId targetId)
		{
			TD_DbPINVOKE.OdDbSortentsTable_moveBelow(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds), OdDbObjectId.getCPtr(targetId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void moveAbove(OdDbObjectIdArray entityIds, OdDbObjectId targetId)
		{
			TD_DbPINVOKE.OdDbSortentsTable_moveAbove(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds), OdDbObjectId.getCPtr(targetId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void swapOrder(OdDbObjectId firstId, OdDbObjectId secondId)
		{
			TD_DbPINVOKE.OdDbSortentsTable_swapOrder(this.swigCPtr, OdDbObjectId.getCPtr(firstId), OdDbObjectId.getCPtr(secondId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbObjectId blockId()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbSortentsTable_blockId(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool firstEntityIsDrawnBeforeSecond(OdDbObjectId firstID, OdDbObjectId secondID)
		{
			bool result = TD_DbPINVOKE.OdDbSortentsTable_firstEntityIsDrawnBeforeSecond(this.swigCPtr, OdDbObjectId.getCPtr(firstID), OdDbObjectId.getCPtr(secondID));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getFullDrawOrder(OdDbObjectIdArray entityIds, byte honorSortentsMask)
		{
			TD_DbPINVOKE.OdDbSortentsTable_getFullDrawOrder__SWIG_0(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds), honorSortentsMask);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getFullDrawOrder(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSortentsTable_getFullDrawOrder__SWIG_1(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getRelativeDrawOrder(OdDbObjectIdArray entityIds, byte honorSortentsMask)
		{
			TD_DbPINVOKE.OdDbSortentsTable_getRelativeDrawOrder__SWIG_0(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds), honorSortentsMask);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getRelativeDrawOrder(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSortentsTable_getRelativeDrawOrder__SWIG_1(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setRelativeDrawOrder(OdDbObjectIdArray entityIds)
		{
			TD_DbPINVOKE.OdDbSortentsTable_setRelativeDrawOrder(this.swigCPtr, OdDbObjectIdArray.getCPtr(entityIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setAbsoluteDrawOrder(HandlePairsArray handlePairs)
		{
			TD_DbPINVOKE.OdDbSortentsTable_setAbsoluteDrawOrder(this.swigCPtr, HandlePairsArray.getCPtr(handlePairs));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getAbsoluteDrawOrder(HandlePairsArray handlePairs)
		{
			TD_DbPINVOKE.OdDbSortentsTable_getAbsoluteDrawOrder(this.swigCPtr, HandlePairsArray.getCPtr(handlePairs));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdResult dwgInFields(OdDbDwgFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbSortentsTable_dwgInFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dwgOutFields(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdDbSortentsTable_dwgOutFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdResult dxfInFields(OdDbDxfFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbSortentsTable_dxfInFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dxfOutFields(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdDbSortentsTable_dxfOutFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult subGetClassID(IntPtr pClsid)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbSortentsTable_subGetClassID(this.swigCPtr, pClsid);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
